<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>computed</title>
  <script src="../assets/js/vue.js"></script>
</head>
<body>
  <h1>computed</h1>
  <hr>
  <div id="app">
    {{ newPrice }}
    <ol>
      <li v-for="(item) in reverseNewsList">{{ item.date }}-{{ item.title }}-{{ item.content }}</li>
    </ol>
  </div>
  <script>
    var vue = new Vue({
      el: '#app',
      data: {
        price: 100,
        newsList: [{
          date: '2017/06/27',
          title: '111',
          content: '111content'
        }, {
          date: '2017/06/28',
          title: '222',
          content: '222content'
        }, {
          date: '2017/06/29',
          title: '333',
          content: '333content'
        }]
      },
      computed: {
        // 这里的属性名不能和data中的一样，这里的属性必须以函数的形式存在
        newPrice: function() {
          return this.price + '元'
        },
        reverseNewsList: function() {
          return this.newsList.reverse();
        }
      }
    })
  </script>
</body>
</html>